package com.fzy.core.system.service;

import java.util.LinkedList;
import java.util.List;

import com.fzy.core.BaseService;
import com.fzy.core.Page;
import com.fzy.core.PageForm;

public class EntityService extends BaseService {
	
	EntityListMapper entityListMapper;
	
	public Page list(EntityQuery entityQuery) {
		String sql = "select * from t_entity where status = '1'";
		List params = new LinkedList();
//		sql += getConditionSql(entityQuery.getVprov_id(), "vprov_id =", params);
//		sql += getConditionSql(entityQuery.getVcity_id(), "vcity_id =", params);
//		sql += getConditionSql(entityQuery.getVdist_id(), "vdist_id =", params);
//		sql += getConditionSql(entityQuery.getVtype(), "vtype =", params);
//		sql += getConditionSql(entityQuery.getVyear(), "vyear =", params);
		
		String orders = "";
//		if("provinceId".equalsIgnoreCase(entityQuery.getOrderBy())){
//			if("desc".equalsIgnoreCase(entityQuery.getOrder())){
//				orders += " order by vprov_id desc, vcity_id, vdist_id";
//			}
//			if("asc".equalsIgnoreCase(entityQuery.getOrder())){
//				orders += " order by vprov_id, vcity_id, vdist_id";
//			}
//		}
//		orders += getOrderSql("vtype","vtype", (PageForm)entityQuery);
//		orders += getOrderSql("year","vyear", (PageForm)entityQuery);		
//		orders += getOrderSql("planNum", "nplan_num",(PageForm)entityQuery);
//		if(orders.length() < 1)
//			orders = " order by vprov_id, vcity_id, vdist_id";
		sql += orders;
		
		Page page = queryPage(sql, params.toArray(), entityListMapper, entityQuery);
		return page;
	}

	public void setEntityListMapper(EntityListMapper entityListMapper) {
		this.entityListMapper = entityListMapper;
	}
	
}
